<?php
        namespace App\Model;
        use Illuminate\Database\Eloquent\Model;
        use Illuminate\Support\Facades\DB;
	use Illuminate\Support\Facades\Input;
	use Illuminate\Http\Request;
	use  Session;
	use Illuminate\Support\Facades\Crypt;
        class User extends Model{
	       protected $table = 'mo_user';  
    	       public $timestamps = false; 
               public  function get_verify($data){
             return DB::table($this->table)->insertGetId($data); 
        }
	public function check_user($data){
	       $u_sign     = $data['u_sign'];
	      if($u_sign == '1'){        
	       $u_name     = $data['u_name'];
	       $u_password = $data['u_password'];
	       $arr=array("u_email","u_name","u_phone");
	       $arrData=array();
	       $okData=array();
	       foreach($arr as $k=> $v){
		$data = DB::table($this->table)->where($v,'=',$u_name)->first();
		if(count($data)){
		  //var_dump($data->u_password);die;
		  $okData['u_password']=$data->u_password;
		  $okData['u_name']=$data->u_name;
		  $okData['u_id']=$data->uid;
		  $okData['u_salt']=$data->u_salt;
		  return $okData;
		 }else{
		   $arrData[]=$k;
		 }
		 if(count($arrData) == 3){
		   return "账号不存在";
		 }
		}
	      }
	    }
	public function select_data($table,$where,$type=1){
	  if($type==1){
	  	return DB::table($table)->where($where)->first();
	  }else if($type ==2){
		return DB::table($table)->where($where)->get();
	   }
	}
	public function linkage($table,$where,$pid=0){
			$data = DB::table($table)->select('r_id','r_city')->where($where)->get();
			return $data;
		}
	public function updataData($table,$where,$data){
		return DB::table($table)->where($where)->update($data);
	}
	public function linkconent($table,$where,$pid=0){
                 $data = DB::table($table)->select('t_g_id','t_city')->where($where)->get();
		 return $data;
	}
	public function check_session(){
		if( Session::has('u_id') && Session::has('u_name')){
			return true;
		}else{
			return false;
		 }	
	}
	public function del_data($table,$where){
	      return DB::table($table)->where($where)->delete();
	}
}
?>

